function getBasePath(){
	var els = document.getElementsByTagName('script'), src;
	for (var i = 0, len = els.length; i < len; i++) {
		src = els[i].src || '';
		if (/UI\/js\/login.js/.test(src)) {
			return src.replace(/UI\/js\/login.js/,"");
		}
	}
	return '';
}
function positionMiddle(){
	var top = (document.documentElement.clientHeight-$(".alumniLogin").height())/2;
	if(top < 5){
		top = 5;
	}
	$(".alumniLogin").css("margin-top",top);
}
function showNotice(msg){
	$(".loginNotice").html(msg);
}
$(document).ready(function(){
	if(top.location.href != location.href){
		top.location.href = location.href;
	}
	
	var glbBasePath = getBasePath();
	//残生随机数
	var randomnum = Math.floor(Math.random()*(3))+1;
	var mainBg = glbBasePath+"image/loginMainbg"+randomnum+".jpg";
	var mainCntBg = glbBasePath+"image/loginMaincnt"+randomnum+".jpg";
	$(".mainBg").css("background","url("+mainBg+") repeat-x left top");
	$(".mainBg .mainCnt").css("background","url("+mainCntBg+") repeat-x left top");

	$(".loginTxt,.loginPwd").click(function(){
		$(this).find(".loginInput").focus();
	});
	$(".loginInput").focus(function(){
		var parent = $(this).parent();
		if(parent.hasClass("loginTxt")){
			parent.addClass("loginTxtFocus").removeClass("loginTxt");
		}
		if(parent.hasClass("loginPwd")){
			parent.addClass("loginPwdFocus").removeClass("loginPwd");
		}
	}).blur(function(){
		if($(this).val()==""){
			var parent = $(this).parent();
			if(parent.hasClass("loginTxtFocus")){
				parent.addClass("loginTxt").removeClass("loginTxtFocus");
			}
			if(parent.hasClass("loginPwdFocus")){
				parent.addClass("loginPwd").removeClass("loginPwdFocus");
			}
		}
	}).select(function(){
	});
	$(".loginReg").click(function(){
		top.location.href = glbBasePath+"Html/zhuce.html";
	});
	
	$("<iframe name='loginCheckFrame' id='loginCheckFrame' style='display:none'></iframe>").appendTo($("#loginForm"));
	$("#loginForm").attr("target","loginCheckFrame");

});